/*
 * @lc app=leetcode.cn id=1773 lang=javascript
 *
 * [1773] 统计匹配检索规则的物品数量
 */

// @lc code=start
/**
 * @param {string[][]} items
 * @param {string} ruleKey
 * @param {string} ruleValue
 * @return {number}
 */
var countMatches = function (items, ruleKey, ruleValue) {
  return items.filter(([type, color, name]) => {
    if (ruleKey === 'type') {
      return ruleValue === type;
    }
    if (ruleKey === 'color') {
      return ruleValue === color;
    }
    return ruleValue === name;
  }).length;
};
// @lc code=end

